home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / sink.lua < prev    next >
Text File  |  2004-01-29  |  4KB  |  115 lines

  1. -- sink state machine
  2.  
  3. beginStateMachine()
  4.  
  5.     onMsg("buildMenu", function(msg)
  6.     
  7.         if (repairMenu()) then return end
  8.     
  9.         -- build the pie menu
  10.         clearPieMenu();
  11.         button = addPieMenuButton("pm_washHands", "washHands");
  12.         button.addDescription(ACTIVITY, "washHands");
  13.         button = addPieMenuButton("pm_washDishes", "washDishes");
  14.         button.addDescription(ACTIVITY, "washDishes");
  15.         button.addDescription(ACTIVITY, "improvePlateTidiness");
  16.         button.addIcon("guiIconWohnung");
  17.         -- button.addIcon("guiIconHygiene");
  18.     end )
  19.  
  20.     -- 
  21.     onMsg("washHands", function(msg)
  22.         -- get the game object server
  23.         local gameObjectServer = getGameObjectServer();
  24.         -- get character who initiated this action
  25.         local character = getStateObjectFromID(msg.sender);
  26.         -- walk to the closest action point
  27.         local actionPoint = character.getFreeActionPoint(this, "washHands");
  28.         if (actionPoint) then
  29.             -- get the walk state object
  30.             local wso = character.walkSO;
  31.             if (wso.walkToActionPoint(actionPoint)) then
  32.                 wso.queueStateMachine("sinkChar.washHandsStart", this);
  33.             else
  34.                 print("no path found");
  35.                 instantAbort(character, EMOTICON_NOPATH, "emoThink")
  36.             end
  37.         else
  38.             print("no action point found");
  39.             instantAbort(character, EMOTICON_CANNOT, "emoThink")
  40. --            character.setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  41. --            sendMsg("emoThink", character.walkSO);
  42.         end
  43.     end )
  44.     
  45. --    onMsg("washDishes", function(msg)
  46. --        -- get the game object server
  47. --        local gameObjectServer = getGameObjectServer();
  48. --        -- get character who initiated this action
  49. --        local character = getStateObjectFromID(msg.sender);
  50. --        -- walk to the closest action point
  51. --        local actionPoint = character.getFreeActionPoint(this, "washHands");
  52. --        if (actionPoint) then
  53. --            -- get the walk state object
  54. --            local wso = character.walkSO;
  55. --            if (wso.walkToActionPoint(actionPoint)) then
  56. --                wso.queueStateMachine("sinkChar.washDishes", this);
  57. --            else
  58. --                print("no path found");
  59. --                character.setEmoticon(EMOTICON_NOPATH, EMOTICON_DELAY);
  60. --                sendMsg("emoThink", character.walkSO);
  61. --            end
  62. --        else
  63. --            print("no action point found");
  64. --            character.setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  65. --            sendMsg("emoThink", character.walkSO);
  66. --        end
  67. --    end )
  68.     
  69.     
  70.     onMsg("washDishes", function(msg)
  71.         -- get character who initiated this action
  72.         local character = getStateObjectFromID(msg.sender);
  73.         -- get the walk state object
  74.         local wso = character.walkSO;
  75.         local wsoContext = StateMachineContext();
  76.         wsoContext.storeData("washState", "sinkChar.washDishesStart");
  77.         wso.queueStateMachine("collectDishesChar.findDishes", this, wsoContext);
  78. --wsoContext.storeData("numDishes", 2);
  79. --wso.queueStateMachine("collectDishesChar.gotoDishwasher", this, wsoContext);
  80.     end )
  81.     
  82.     
  83.     
  84.     
  85.     
  86.     -- repair
  87.     onMsg("repair", function(msg)
  88.     
  89.         print("onMsg repair");
  90.         -- get character who initiated this action
  91.         local character = getStateObjectFromID(msg.sender);
  92.         -- walk to the closest action point
  93.         local actionPoint = character.getFreeActionPoint(this, "repair");
  94.         -- get the walk state object
  95.         local wso = character.walkSO;
  96.         if (actionPoint) then
  97.             -- create state machine contexts
  98.             local wsoContext = StateMachineContext();
  99.             -- store the action point
  100.             wsoContext.storeData("actionPointName", actionPoint.getName());
  101.             if (wso.walkToActionPoint(actionPoint)) then
  102.                 wso.queueStateMachine("repairChar.repairStart", this, wsoContext);
  103.             else
  104.                 print("no path found");
  105.                 instantAbort(character, EMOTICON_NOPATH, "emoThink")
  106.             end
  107.         else
  108.             print("no action point found");
  109.             instantAbort(character, EMOTICON_CANNOT, "emoThink")
  110.         end
  111.     end )
  112.                         
  113.             
  114. endStateMachine()
  115.